//
//  MqGuideViewController.m
//  Meiqi
//
//  Created by TwistedFate on 16/1/28.
//  Copyright © 2016年 KFC. All rights reserved.
//

#import "MqGuideViewController.h"
#import "RootViewController.h"
@interface MqGuideViewController ()
<UIScrollViewDelegate>
@end

@implementation MqGuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    [scrollView setContentSize:CGSizeMake(kScreenWidth * 4, 0)];
    [scrollView setPagingEnabled:YES];  //视图整页显示
    //    [scrollView setBounces:NO]; //避免弹跳效果,避免把根视图露出来
    scrollView.delegate = self;

    UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    [imageview setImage:[UIImage imageNamed:@"tieta.jpg"]];
    [scrollView addSubview:imageview];

    UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, kScreenHeight)];
    [imageview1 setImage:[UIImage imageNamed:@"shamo.jpg"]];
    [scrollView addSubview:imageview1];

    UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth * 2, 0, kScreenWidth, kScreenHeight)];
    [imageview2 setImage:[UIImage imageNamed:@"shanshui.jpg"]];
    [scrollView addSubview:imageview2];

    UIImageView *imageview3 = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth * 3, 0, kScreenWidth, kScreenHeight)];
    [imageview3 setImage:[UIImage imageNamed:@"mirror_reflection-wallpaper-2880x1800.jpg"]];
    imageview3.userInteractionEnabled = YES;    //打开imageview3的用户交互;否则下面的button无法响应
    [scrollView addSubview:imageview3];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//在imageview3上加载一个透明的button
    [button setTitle:@"跳过>>" forState:UIControlStateNormal];
    [button setFrame:CGRectMake(kScreenWidth - 60, 20, 60, 40)];
    [button addTarget:self action:@selector(firstpressed) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];

    [self.view addSubview:scrollView];
}

- (void)firstpressed
{

    RootViewController *infoVC = [[RootViewController alloc] init];
    
    [self presentViewController:infoVC animated:YES completion:nil];
    
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
//    NSLog(@"%f",scrollView.contentOffset.x);
    if (scrollView.contentOffset.x > kScreenWidth * 3) {
        
        [self firstpressed];
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
